<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form class="form-horizontal form-label-left" action="" method="post" enctype="multipart/form-data">
    论文题目：<input type="text" id="title"><br/>
    类型：<select id="leixin">

    </select><br/>
    论文摘要 <textarea id="paperSummary" rows="10" cols="30"></textarea><br/>
    论文文件：<input type="file"><br/>
    <input type="button" id="baocun" value="保存">
    <input type="button" onclick="fanhui()" value="返回">
</form>
</body>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
    function fanhui(){
        window.location.href="/papermanage/login";
    }

    $(function () {
        $.ajax({
            "url":"/papermanage/ttype/selty",
            "type":"get",
            "dataType":"json",
            "success":function(a){
                var selTyp = a.result["selTyp"];
                for(var i = 0 ; i < selTyp.length ; i++){
                    var html = "";
                    html+="<option value='"+selTyp[i].typeName+"'>"+selTyp[i].typeName+"</option>"
                    $('#leixin').append(html);
                }
            },
            "error":function(){
                alert("服务器错误");
            }
        });
    })

    $('#baocun').click(function () {
        var title = $('#title').val();
        var paperSummary = $('#paperSummary').val();
        var typeCode = $("#leixin option:selected").val();
        $.ajax({
            "url":"/papermanage/tpaper/insertTp",
            "type":"get",
            "data":{
                "title":title,
                "paperSummary":paperSummary,
                "typeCode":typeCode
            },
            "dataType":"json",
            "success":function(a){
                var num = parseInt(a.result["num"]);
                if(num>0){
                    alert("添加成功")
                    window.location.href="/papermanage/chaxun";
                }else {
                    alert("添加失败")
                    window.location.href="/papermanage/insert";
                }
            },
            "error":function(){
                alert("服务器错误");
            }
        });
    })
</script>
</html>